from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

# 设置环境变量
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'meiduo_mall.settings.dev')

# 创建celery对象
app = Celery('meiduo_mall')

# 加载配置文件
app.config_from_object('celery_tasks.config', namespace='CELERY')

# 注册任务
app.autodiscover_tasks(["celery_tasks.test.tasks", "celery_tasks.sms.tasks", "celery_tasks.email.tasks"])


# 启动celery任务
# celery -A celery_tasks.main worker -l info
# celery -A celery_tasks.main worker --pool=solo -l info(windows)

# @app.task(bind=True)
# def debug_task(self, count):
#     import time
#     for i in range(0, count):
#         time.sleep(1)
#         print('i = %s' % i)
